from threading import Thread, Lock
import time


lock = Lock()
tickets = []
for i in range(1, 501):
    tickets.append(i)


def window(w):
    while tickets:
        lock.acquire()
        print("%s -- %s" % (w, tickets.pop(0)))
        lock.release()
        time.sleep(0.1)


if __name__ == '__main__':
    jobs = []
    for win in range(11):
        t = Thread(target=window, args=(win,))
        jobs.append(t)
        t.start()
    for i in jobs:
        i.join()
    print("售罄")

